<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
session_start();
//$UserID = $_SESSION['ID'];
$UserID = '05177291244';
include_once('Mysql_connect.inc');//启动连接，连接名：$conn

echo '<table>';
echo '<tr>';
echo '<th>college</th>';
echo '<th>teacher name</th>';
echo '<th>course_id</th>';
echo '<th>subject</th>';
echo '<th>class_room</th>';
echo '<th>credit_hour</th>';
echo '<th>description</th>';
echo '</tr>';
$result = mysqli_query($conn, " SELECT
college.college,
teacher.name,
registeredcourse.course_id,
registeredcourse.subject,
course.class_room,
course.credit_hour,
course.description
FROM
registeredcourse ,
college ,
teacher ,
course
WHERE
registeredcourse.student_id =  '$UserID' AND
registeredcourse.course_id =  course.course_id AND
college.id =  course.college AND
teacher.teacher_id =  course.teacher_id ");
while (($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) != NULL) {
    echo '<tr>';
    echo '<td>' . $row['college'] . '</td>';
    echo '<td>' . $row['name'] . '</td>';
    echo '<td>' . $row['course_id'] . '</td>';
    echo '<td>' . $row['subject'] . '</td>';
    echo '<td>' . $row['class_room'] . '</td>';
    echo '<td>' . $row['credit_hour'] . '</td>';
    echo '<td>' . $row['description'] . '</td>';
    echo '</tr>';
}
//mysqli_free_result($result);
echo '</table>';
echo '<hr>';


echo '<table>';
echo '<tr>';
echo '<th>course_id</th>';
echo '<th>teacher_name</th>';
echo '<th>subject</th>';
echo '<th>credit_hour</th>';
echo '<th>description</th>';
echo '<th>college</th>';
echo '<th>class_room</th>';
echo '<th>Status</th>';
echo '</tr>';
$result_Yet = mysqli_query($conn, "SELECT
course.course_id,
course.subject,
course.credit_hour,
course.description,
course.class_room,
college.college,
teacher.name
FROM
course
Left Join registeredcourse ON registeredcourse.course_id = course.course_id AND registeredcourse.student_id <> '$UserID' ,
college ,
teacher
WHERE
registeredcourse.course_id IS NULL  AND
course.teacher_id =  teacher.teacher_id AND
course.college =  college.id
 ");

while ($row_yet = mysqli_fetch_array($result_Yet, MYSQLI_ASSOC)!= NULL ) {
    echo '<tr>';
    echo '<td>' . $row_yet['course_id'] . '</td>';
    echo '<td>' . $row_yet['name'] . '</td>';
    echo '<td>' . $row_yet['subject'] . '</td>';
    echo '<td>' . $row_yet['credit_hour'] . '</td>';
    echo '<td>' . $row_yet['description'] . '</td>';
    echo '<td>' . $row_yet['college'] . '</td>';
    echo '<td>' . $row_yet['class_room'] . '</td>';
    echo '<td>=SELECT=</td>';
    echo '</tr>';
}
mysqli_free_result($result_Yet);
echo '</table>';
include_once('Mysql_unconnect.inc'); //断开连接
?>
